#pragma once
#include <fstream>
#include <iostream>
#include <sstream>
#include <opencv2/opencv.hpp>
#include "NvInfer.h"
#include "NvOnnxParser.h"

#include <opencv2/cudaimgproc.hpp>
#include <opencv2/cudawarping.hpp>
#include <opencv2/cudafilters.hpp>
#include <opencv2/cudaarithm.hpp>



struct DetectResult {
	int classId;
	float score;
	cv::Rect box;
};

using namespace nvinfer1;
using namespace nvonnxparser;
using namespace cv;

class YOLOv81112TRTDetector {
public:
	void initConfig(std::string enginefile, float confidence_threshold, float score_threshold);
	void detect(cv::Mat& frame, std::vector<DetectResult>& results);
	~YOLOv81112TRTDetector();
private:
	float confidence_threshold = 0.4;
	float score_threshold = 0.25;
	int input_w;
	int input_h;
	int output_h;
	int output_w;
	ICudaEngine* engine{ nullptr };
	IExecutionContext* context{ nullptr };
	IRuntime* runtime{ nullptr };
	void* buffers[2] = { NULL, NULL };
	std::vector<float> prob;
	cudaStream_t stream;
};